<?php
/**
 * @version		$Id: view.html.php 2011.08.11 thierry $
 * @package		admin.views.links
 * @subpackage	com_projid
 * @copyright	Copyright (C) 2011 Pojid All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.view');

class ProjidViewlinks extends JView
	{
		protected $birt_list;
		protected $items;
		protected $pagination;
		protected $state;
			
		function display($tpl = null) 
			{
			
		 
	// Check for errors.

	// Assign data to the view
				$this->items = $this->get('Items');
				$this->params = $this->get('Params');
				$this->pagination = $this->get('Pagination');
				$this->state = $this->get('State');
				
				if (count($errors = $this->get('Errors'))) 
				{
					JError::raiseError(500, implode('<br />', $errors));
					return false;
				}
					
				$this->ordering = array();
				foreach ($this->items as $item) {
					$this->ordering[$item->report_id][] = $item->link_id;
				}
				
				// List of birt names
				$db =& JFactory::getDBO();
				$query = "SELECT DISTINCT birt_name FROM #__projid_birt ORDER BY birt_name";
				$db->setQuery($query);
				$list_birts = $db->loadObjectList();
				// Check for a database error.
				if ($error = $db->getErrorMsg()) {
					JError::raiseWarning(500, $error);
					return false;
				}
				$options = array();
				foreach ($list_birts as &$list_birt) {
					$options[]	= JHtml::_('select.option', $list_birt->birt_name, JText::_($list_birt->birt_name));
				}

				$this->assign('birt_list', $options);
		
	// Set the toolbar
				$this->addToolBar();
		 
	// Display the template
				parent::display($tpl);
	// Set the document
				$this->setDocument();
	}
 //TOOLBAR
	protected function addToolBar() 
	{
		JToolBarHelper::title(JText::_('COM_PROJID_MANAGER_LINK'),'link');
		JToolBarHelper::deleteListX('', 'links.delete');
		JToolBarHelper::editListX('link.edit');
		JToolBarHelper::addNewX('link.add');
		
	}
/**PROPERTIES**/
	protected function setDocument() 
	{
		$document = JFactory::getDocument();
		$document->setTitle(JText::_('COM_PROJID_ADMINISTRATION'));
	}
}
